package com.zut.demo1.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.URLEncoder;

@Controller
public class Loginout {

    @GetMapping("/loginout")
    public void Loginout(HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {
        session.invalidate();
        // ids的退出地址，ids6.wisedu.com为ids的域名  authserver为ids的上下文，logout为固定值
        String casLogoutURL = "http://authserver.zut.edu.cn/authserver/logout";
        // service后面带的参数为应用的访问地址，需要使用URLEncoder进行编码
        String redirectURL=casLogoutURL+"?service="+ URLEncoder.encode("https://authserver.zut.edu.cn/authserver/login?service=http%3A%2F%2F10.205.1.26%3A8080%2F");
        response.sendRedirect(redirectURL);
    }
}
